using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class ObjB : MonoBehaviour,I_Subject
{
    private List<I_Observer> observerList = new ();

    public void SenderMessage(I_Observer observer)
    {
        observerList.Add(observer);
    }
    public void RemoveMessage(I_Observer observer)
    {
        observerList.Remove(observer);
    }


    public void TriggerMessage()
    {
        foreach(var observer in observerList)
        {
            observer.CowBSkill();
        }
    }

    void OnEnable()
    {
      SenderMessage(new ObjC());
    }

    // Update is called once per frame
    void Update()
    {
        if(Keyboard.current.spaceKey.wasPressedThisFrame)
        {
            //TriggerMessage();
            EventCenterExample.Instance.TriggerEvent("ObjA");
        }
    }
    void OnDisable()
    {
        foreach(var item in observerList)
        {
            RemoveMessage(item);
        }
    }
    
 

}
